package com.isky.visual.redis;

import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

import java.util.HashMap;

/**
 * @ClassName : RedisConfig
 * @Description : redis 的配置类
 * @Author :wudl
 * @Date: 2020-04-12 14:25
 */
@Data
@Configuration
public class RedisConfig {

    @Value("${spring.redis.host}")
    private  String host;

    @Value("${spring.redis.port}")
    private  int port;

    @Value("${spring.redis.timeout}")
    private  int timeout;

    @Value("${spring.redis.password}")
    private  String password;

    @Value("${spring.redis.jedis.pool.max-wait}")
    private  int maxWait;

    @Value("${spring.redis.jedis.pool.max-idle}")
    private  int maxIdle;

    @Value("${spring.redis.jedis.pool.minidle}")
    private  int minIdle;

//    @Value("${spring.redis.jedis.pool.timeout}")
//    private int timeout;


    @Bean("jedisPool")
    public JedisPool jedisPool() {
        JedisPoolConfig config = new JedisPoolConfig();
        config.setMinIdle(minIdle);
        config.setMaxWaitMillis(maxWait);
        config.setMaxIdle(maxIdle);


        return new JedisPool(config, host, port, timeout,password,0);
    }


}
